<?= $this->element('gmap_config') ?>

<?= $this->Html->css('jquery-gmaps.min') ?>
<?= $this->Html->script('jquery-gmaps-1.0.0.min') ?>
<?= $this->Html->script('map') ?>

<h1>Podešavanja</h1>

<?= $this->Form->create('Settings', array(
    'url'      => '/admin/index',
    'onsubmit' => "PUT('/admin/index', $(this).serialize()); return false;"
)) ?>

    <div class="left">
        <p><?= $this->Form->label('name', 'Naziv Sajta:', array('class'=>'first')) ?>
        <?= $this->Form->text('name', array(
            'value'       => @$Settings->name,
            'class'       => 'large'
        )) ?></p>
        
        <p><?= $this->Form->label('address', 'Adresa:') ?>
        <?= $this->Form->text('address', array(
            'value'       => @$Settings->address,
            'class'       => 'large'
        )) ?></p>
        
        <p><?= $this->Form->label('phone', 'Telefon:') ?>
        <?= $this->Form->text('phone', array(
            'value'       => @$Settings->phone
        )) ?></p>
        
        <p><?= $this->Form->label('email', 'E-Mail:') ?>
        <?= $this->Form->text('email', array(
            'value'       => @$Settings->email,
            'class'       => 'medium'
        )) ?></p>
        
        <p>
            <span class="left" style="width:200px">
                <?= $this->Form->label('pib', 'PIB:', array('class'=>'inline')) ?>
                <?= $this->Form->text('pib', array(
                    'value'       => @$Settings->pib,
                    'class'       => 'small'
                )) ?>
            </span>
            <span class="left">
                <?= $this->Form->label('matbr', 'MAT.BR:') ?>
                <?= $this->Form->text('matbr', array(
                    'value'       => @$Settings->matbr,
                    'class'       => 'small'
                )) ?>
            </span><br clear="all">
        </p>
        
        <p><?= $this->Form->label('keywords', 'Ključne reči:') ?>
        <?= $this->Form->text('keywords', array(
            'value'       => @$Settings->keywords,
            'class'       => 'large',
            'placeholder' => 'Ključne reči...'
        )) ?></p>
        
        <p><?= $this->Form->label('description', 'Kratak Opis:') ?>
        <?= $this->Form->textarea('description', array(
            'value'       => @$Settings->description,
            'placeholder' => 'Kratak opis sajta...',
            'style'       => 'width:400px'
        )) ?></p>
        
        <p style="margin-top:50px">
            <?= $this->Form->submit('Sačuvaj') ?>
        </p>
        <?= $this->Session->flash() ?>
    </div>
    <?= $this->Form->hidden('latlng', array( 'value' => @$Settings->latlng)) ?>
    <div id="map" style="width:400px;height:400px;float:left;margin-left:10px"></div>

<?= $this->Form->end() ?>
<script type="text/javascript">
$(function(){
    var map     = $('#map');
    var gmap    = map.data('gmap');
    var marker  = gmap.map.destination.marker;
    marker.setDraggable(true);
    marker.addListener('dragend', function(e){
        var lat = e.latLng.lat();
        var lng = e.latLng.lng();
        gmap.map.object.setCenter(e.latLng);
        map.prev().val(lat+';'+lng);
    });
});
</script>